package cn.edu.huas.shopping.utils;

import jakarta.servlet.http.HttpServletRequest;

import java.io.BufferedReader;
import java.io.IOException;
/*
* 工具类用来读取payload的数据
* */
public class PayLoadDataReader {

    public static String parse(HttpServletRequest request)throws IOException {
        //对payload及负载的数据要通过流的形式来获取
        BufferedReader reader=request.getReader();
        StringBuilder sb=new StringBuilder();
        char[] buff=new char[1024];
        int size=-1;
        while ((size=reader.read(buff))!=-1){
            sb.append(buff,0,size);
        }
        return sb.toString();
    }
}
